<!--首页页面-->
<style lang="less">
.tousu {
  .smallForm {
    width: 100%;
    display: inline-block;
  }
  .modal-pump {
    .ivu-modal-body {
      float: left;
    }
  }
  #map {
    width: 100%;
    height: 400px;
  }
  .ivu-badge-count {
    top: 0 !important;
    right: 5px !important;
  }
}
.reprotImg {
  width: 50px;
  height: 50px;
  float: left;
  margin-right: 5px;
}
.bg-red {
  color: red;
}
.bg-orange {
  color: orange;
}
</style>

<template>
  <i-col span="24"
         class="tousu">
    <Card :bordered="false">
      <p slot="title"
         class="white">河流事件</p>
      <div style="position:relative;">
        <Form :model="searchItem"
              class="smallForm">
          <Input v-model="searchItem.river_name"
                 style="width:19%;margin-right: 15px;"
                 :maxlength="30"
                 placeholder="请输入河流名称"></Input>
          <Input v-model="searchItem.chref_name"
                 style="width:19%;margin-right: 15px;"
                 :maxlength="30"
                 placeholder="请输入河长名称"></Input>
          <Input v-model="searchItem.report_no"
                 style="width:19%;margin-right: 15px;"
                 :maxlength="30"
                 placeholder="请输入事件编号"></Input>
          <Input v-model="searchItem.overday"
                 style="width:20%;margin-right: 15px;"
                 :maxlength="30"
                 placeholder="请输入超时天数"></Input>
          <DatePicker @on-change="change"
                      format="yyyy-MM-dd"
                      type="daterange"
                      placeholder="请选择事件日期"
                      style="width: 19%;margin:15px 15px 0 0;"></DatePicker>
          <dep-select @getData="getDepData"
                      style="width:19%;margin-right: 15px;"></dep-select>
          <Checkbox v-model="searchItem.can_use">只显示可操作</Checkbox>
          <Checkbox v-model="searchItem.is_multiple">是否为多次事件河流</Checkbox>
        </Form>
        <Button type="info"
                style="position:absolute;top:0;right:10%"
                @click="getComplaint('1',type_solve_is)">搜索</Button>
      </div>
    </Card>
    <Tabs v-model="topTabs"
          @on-click="aa">
      <TabPane label="处理中"
               name="处理中">
        <Table ref="table"
               :row-class-name="rowClassName"
               :data="solveData"
               :columns="complaintColumns"
               stripe></Table>
      </TabPane>
      <TabPane label="已处理"
               name="已处理">
        <Table ref="table"
               :data="completeData"
               :columns="complaintColumns"
               stripe></Table>
      </TabPane>
      <TabPane label="我发起的事件"
               name="我发起的事件">
        <Table ref="table"
               :data="myData"
               :columns="complaintColumns"
               stripe></Table>
      </TabPane>
    </Tabs>
    <Page class="pull-right"
          :total="Page.total"
          :current="Page.current"
          :page-size="Page.pageSize"
          size="small"
          show-total
          @on-change="changePage"></Page>
    <Modal v-model="comfirmModal"
           title="处理事件"
           width="600">
      <Form :model="formItem1"
            :label-width="60">
        <Form-item label="处理结果"
                   prop="solve_result2">
          <Input v-model="solve_result2"
                 type="textarea"
                 :maxlength="800"
                 placeholder="处理结果"></Input>
        </Form-item>
        <Form-item label="上传图片"
                   v-if="solve">
          <div class="demo-upload-list"
               v-for="item in uploadList">
            <template v-if="item.status === 'finished'">
              <img :src="item.url">
              <div class="demo-upload-list-cover">
                <Icon type="ios-trash-outline"
                      @click.native="handleRemove(item)"></Icon>
              </div>
            </template>
            <template v-else>
              <Progress v-if="item.showProgress"
                        :percent="item.percentage"
                        hide-info></Progress>
            </template>
          </div>
          <Upload ref="upload"
                  :show-upload-list="false"
                  :on-success="handleSuccess"
                  :format="['jpg','jpeg','png']"
                  :max-size="2048000"
                  :on-format-error="handleFormatError"
                  :on-exceeded-size="handleMaxSize"
                  :before-upload="handleBeforeUpload"
                  multiple
                  type="drag"
                  :action="uploadUrl"
                  style="display: inline-block;width:58px;">
            <div style="width: 58px;height:58px;line-height: 58px;">
              <Icon type="camera"
                    size="20"></Icon>
            </div>
          </Upload>
        </Form-item>
        <Form-item label="审核图片"
                   v-if="check">
          <div class="demo-upload-list"
               v-for="item in uploadList">
            <template>
              <img :src="item">
              <div class="demo-upload-list-cover">
                <Icon type="ios-eye-outline"
                      @click.native="handleView(item)"></Icon>
              </div>
            </template>
          </div>
        </Form-item>
        <Form-item label="审核结果"
                   v-if="check"
                   prop="reason">
          <Input v-model="reason"
                 type="textarea"
                 :maxlength="800"
                 placeholder="审核结果"></Input>
        </Form-item>
      </Form>
      <div slot="footer">
        <Button type="primary"
                v-if="solve"
                @click="send">确定</Button>
        <Button type="primary"
                v-if="check"
                @click="review('true')">确定通过</Button>
        <Button type="error"
                v-if="check"
                @click="review('false')">不予通过</Button>
        <Button @click="comfirmModal = false">取消</Button>
      </div>
    </Modal>
    <Modal v-model="mapModal"
           width="800">
      <p slot="header"
         style="color:#f60;text-align:center;float: left">
        查看地理位置
      <div>
        <img src="../../../static/img/gis1.png"
             height="30"
             width="30"
             alt="">
        <span>上报人定位</span>
        <img src="../../../static/img/weizhi.png"
             height="30"
             width="30"
             alt="">
        <span>上报人上报事件定位</span>
      </div>
      </p>
      <div id="map"
           style="height: 400px">

      </div>
    </Modal>
    <Modal v-model="printModal"
           class="modal-pump"
           width="800"
           title="市河长办受理咨询投诉登记表">
      <Form :model="formItem"
            :label-width="90">
        <i-col span="12">
          <Form-item label="经办人"
                     prop="confirm_person">
            <Input v-model="confirm_person"
                   :maxlength="12"
                   value="河长办"></Input>
          </Form-item>
          <Form-item label="投诉人"
                     prop="contacts">
            <Input v-model="contacts"
                   :maxlength="5"
                   placeholder="请输入投诉人"></Input>
          </Form-item>
          <Form-item label="联系方式"
                     prop="phone">
            <Input v-model="phone"
                   :maxlength="11 "
                   placeholder="请输入联系方式"></Input>
          </Form-item>
          <Form-item label="河湖名称（河段）"
                     prop="river_name">
            <Input v-model="river_name"
                   :maxlength="12"
                   placeholder="请输入河湖名称（河段）"></Input>
          </Form-item>
        </i-col>
        <i-col span="12">
          <Form-item label="登记编号"
                     prop="report_no">
            <Input v-model="report_no"
                   :maxlength="20"></Input>
          </Form-item>
          <Form-item label="投诉时间"
                     prop="report_time">
            <Input v-model="report_time"
                   :maxlength="20"
                   placeholder="请输入投诉时间"></Input>
          </Form-item>
          <Form-item label="身份证"
                     prop="contacts_id">
            <Input v-model="contacts_id"
                   :maxlength="20"
                   placeholder="请输入身份证"></Input>
          </Form-item>
          <Form-item label="地点"
                     prop="address">
            <Input v-model="address"
                   :maxlength="18"
                   placeholder="地址"></Input>
          </Form-item>
        </i-col>
        <i-col span="24">
          <Form-item label="上级督办意见"
                     prop="advice">
            <Input type="textarea"
                   readonly
                   v-model="advice"
                   :autosize="true"
                   :maxlength="800"
                   placeholder="上级意见"></Input>
          </Form-item>
          <Form-item label="事件描述"
                     prop="overview">
            <Input type="textarea"
                   v-model="overview"
                   :autosize="true"
                   :maxlength="800"
                   placeholder="事件描述"></Input>
          </Form-item>
          <Form-item label="初步办理意见"
                     prop="complete_opinion">
            <Input type="textarea"
                   v-model="complete_opinion"
                   :autosize="true"
                   :maxlength="800"
                   placeholder="初步办理意见"></Input>
          </Form-item>
          <Form-item label="处理结果"
                     prop="solve_result">
            <Input type="textarea"
                   v-model="solve_result"
                   :autosize="true"
                   :maxlength="800"
                   placeholder="处理结果"></Input>
          </Form-item>
          <Form-item label="处理结果图片"
                     prop="solve_file">
            <div v-for="item in showImgLoad"
                 class="reprotImg">
              <img :src="item"
                   @click="handleView(item)"
                   style="width:100%;height:100%;">
            </div>
          </Form-item>
          <Form-item label="回复处理结果"
                     prop="reply_result">
            <Input type="textarea"
                   v-model="reply_result"
                   :autosize="true"
                   :maxlength="800"
                   placeholder="回复处理结果"></Input>
          </Form-item>
          <Form-item label="处理效率评分"
                     v-show="user_type === '1'"
                     prop="score">
            <Rate disabled
                  v-model="score.speed" />
          </Form-item>
          <Form-item label="回复态度评分"
                     v-show="user_type === '1'"
                     prop="score">
            <Rate disabled
                  v-model="score.attitude" />
          </Form-item>
          <Form-item label="综合得分评分"
                     v-show="user_type === '1'"
                     prop="score">
            <Rate disabled
                  v-model="score.merge" />
          </Form-item>
          <Form-item label="群众评价"
                     v-show="user_type === '1'"
                     prop="score">
            <div>{{score.evaluate}}</div>
          </Form-item>
        </i-col>
        <i-col span="24">
          <Table ref="table"
                 :data="jinduData"
                 :columns="jinduColumns"
                 stripe></Table>
        </i-col>
      </Form>

      <div slot="footer">
        <Button type="primary"
                v-if="printshow"
                @click="ok">下载表格</Button>
        <Button @click="printModal = false">取消</Button>
      </div>
    </Modal>
    <Modal v-model="backModal"
           width="500">
      <p slot="header"
         style="color:#f60;text-align:center">
        <Icon type="information-circled"></Icon>
        <span>返回确认</span>
      </p>
      <div style="text-align:center">
        <p>确认返回上级河长办？</p>
        <p style="margin-bottom: 15px">是否继续返回？</p>
        <Form :model="formItem1"
              :label-width="80">
          <Form-item label="返回原因"
                     prop="reason">
            <Input v-model="formItem1.reason"
                   type="textarea"
                   style="width: 95%"
                   :maxlength="800"
                   placeholder="请填写返回原因"></Input><span class="redStar">*</span>
          </Form-item>
        </Form>
      </div>
      <div slot="footer">
        <Button type="error"
                size="large"
                long
                @click="backDep">确认</Button>
      </div>
    </Modal>
    <Modal v-model="companyModal"
           title="指派主办单位和协办单位"
           width="600">
      <Form :model="formItem1"
            :label-width="80">
        <Form-item label="主办单位"
                   prop="host_dep">
          <Select clearable
                  v-model="host_dep">
            <Option v-for="item in host_depList"
                    :value="item"
                    :key="item">{{ item }}</Option>
          </Select>
        </Form-item>
        <Form-item label="协办单位"
                   prop="assist_dep">
          <Select multiple
                  v-model="assist_dep">
            <Option v-for="item in host_depList"
                    :value="item"
                    :key="item">{{ item }}</Option>
          </Select>
        </Form-item>
        <Form-item label="指派建议"
                   v-if="host_dep != ''"
                   prop="chief_advice">
          <Input v-model="chief_advice"
                 type="textarea"
                 style="width: 95%"
                 :maxlength="800"
                 placeholder="请输入指派建议"></Input><span class="redStar">*</span>
        </Form-item>
      </Form>
      <div slot="footer">
        <Button type="primary"
                @click="assDep">确认</Button>
        <Button @click="companyModal = false">取消</Button>
      </div>
    </Modal>
    <Modal title="查看处理结果图片"
           v-model="visible">
      <img :src="imgName"
           v-if="visible"
           style="width: 100%">
    </Modal>
    <Modal v-model="comfirmModal1"
           title="审核处理意见"
           width="600">
      <Form :model="formItem1"
            :label-width="60">
        <Form-item label="处理意见"
                   prop="chref_complete_opinion">
          <Input v-model="chref_complete_opinion"
                 readonly
                 type="textarea"
                 :maxlength="800"
                 placeholder="处理意见"></Input>
        </Form-item>
        <Form-item label="审核描述"
                   prop="reason">
          <Input v-model="reason"
                 :maxlength="800"
                 placeholder="审核描述"></Input>
        </Form-item>
      </Form>
      <div slot="footer">
        <Button type="primary"
                @click="checkIn('true')">确定通过</Button>
        <Button type="error"
                @click="checkIn('false')">不予通过</Button>
        <Button @click="comfirmModal1 = false">取消</Button>
      </div>
    </Modal>
    <Modal v-model="myModal"
           title="河长指派自己河长办主办"
           @on-ok="doMySelf">
      <div style="text-align:center">
        <p style="margin-bottom: 15px;font-size: 16px">河长自己处理事件</p>
      </div>
    </Modal>
    <Modal v-model="printPatrolModal"
           :mask-closable="false"
           @on-ok="printPatrol"
           @on-cancel="printPdf=''"
           title="巡河记录表打印预览"
           width="1200"
           style="text-align: center">
      <iframe id="patrolTable"
              v-if="printPdf"
              style="width:100%;height:700px"
              :src="printPdf"></iframe>
      <img src="../a-picture/img/aPictureNoCount.png"
           v-else
           height="255"
           width="340"
           alt />
      <div slot="footer">
        <Button type="primary"
                @click="printPatrol">打印</Button>
        <Button @click="printPatrolModal = false">取消</Button>
      </div>
    </Modal>
    <lc :row="saveRow"
        ref="lc"></lc>
    <pictures ref="pictures"></pictures>
  </i-col>
</template>

<script>
import lc from 'public/lc';
import picture from 'public/picture';
import { ajaxPost } from 'global/axios';
import storage from 'good-storage';
import { chiefComplaintColumns } from 'common/js/table';
import { complaintColumns } from 'common/js/table';
import depSelect from 'public/depSelect.vue';
import { domain, domain2 } from 'global/setting';
export default {
  components: {
    lc,
    pictures: picture,
    'dep-select': depSelect,
  },
  data () {
    return {
      urlReportNew: '/emergency/report/new',
      complaintList: '/emergency/report/myreport',
      urlShenHe: '/emergency/report/examine',
      urlJieSu: '/emergency/report/over',
      urlJieSu2: '/emergency/report/submit_result',
      docList: '/emergency/report/createdoc',
      urlChangeCherf: '/emergency/report/assign',
      urlAddressList: '/sys/department/distinct',
      urlJinDu: '/bus/record/list',
      urlTreeList: '/sys/department/getTree',
      urlCherfList: '/sys/userinfo/findbyrole',
      urlDepList: '/sys/department/list',
      urlAssignCherf: '/emergency/report/assign_chief',
      urlAssignDep: '/emergency/report/assign_down',
      urlAssignUp: '/emergency/report/back_dep',
      urlHostDepList: '/sys/department/distinct',
      urlAssDep: '/emergency/report/assign_jobdep',
      urlReview: '/emergency/report/examine_result',
      urlMySelf: '/emergency/report/assign_hisself',
      uploadUrl: '',
      chref_complete_opinion: '',
      areaArr: [],
      chief_advice: '',
      reply_result: '',
      myData: [],
      comfirmData: [],
      solveData: [],
      completeData: [],
      fallData: [],
      myModal: false,
      actionPage: '1',
      imgSrc: '',
      topTabs: '',
      chrefTabs: '',
      comfirmModal1: false,
      switch1: false,
      adviceRow: {},
      formItem2: {},
      formItem3: {},
      replay: '',
      saveIndex: '',
      savePhotos: [],
      printModal: false,
      printshow: false,
      Page: {
        current: 1,
        pageSize: 8,
        total: 0,
      },
      formItem: {},
      formItem1: {
        reason: '',
      },
      address: '',
      phone: '',
      contacts: '',
      river_name: '',
      report_time: '',
      report_no: '',
      confirm_person: '',
      is_secrecy: '',
      contacts_id: '',
      overview: '',
      complete_opinion: '',
      complete_opinion2: '',
      solve_result: '',
      row: {},
      type: '',
      mapModal: false,
      comfirmModal: false,
      comfirm: false,
      solve: false,
      type_solve_is: '',
      comfirm_num: '',
      complete_num: '',
      searchItem: {
        river_name: '',
        chref_name: '',
        report_time: [],
        deps: [],
        report_no: '',
        overday: '',
        is_multiple: false,
        can_use: true,
      },
      advice: '',
      complaintColumns: [],
      jinduData: [],
      jinduColumns: [
        {
          title: '过程',
          key: 'overview',
        },
        {
          title: '时间',
          key: 'date_time',
        },
      ],
      uploadList: [],
      solve_result2: '',
      showImgLoad: [],
      username: '',
      dep_name: '',
      userList: [],
      depList: [],
      saveRow: {},
      backModal: false,
      companyModal: false,
      host_dep: '',
      assist_dep: [],
      host_depList: ['暂无数据'],
      check: false,
      reason: '',
      visible: false,
      imgName: '',
      lcUrl: '',
      lcModal: false,
      score: {},
      user_type: '',
      printPdf: '',
      printPatrolModal: false,
    };
  },
  methods: {
    bb (name) {
      if (name === '上报河长') {
        this.username = '';
        this.complete_opinion2 = '';
      } else if (name === '指派河长办') {
        this.dep_name = '';
      }
    },
    changeHzb (data, row) {
      let params = {
        data: {
          _id: row._id,
          report_no: row.report_no,
          dep_name: data,
        },
        url: this.urlChangeCherf,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Message.success({
              content: res.data.message,
            });
            this.getComplaint(this.actionPage, this.type_solve_is);
            this.addBadge();
          } else {
            this.$Message.warning({
              title: res.data.message,
            });
          }
        },
      };
      ajaxPost(params);
    },
    aa (name) {
      if (name === '我发起的事件') {
        this.getMyData();
        return;
      }
      this.getComplaint('1', name);
    },
    showMap (row) {
      this.mapModal = true;

      let center = new qq.maps.LatLng(row.lat, row.lng);
      let center2 = new qq.maps.LatLng(row.con_lat, row.con_lng);
      let map = new qq.maps.Map(document.getElementById('map'), {
        center,
        zoom: 16,
        disableDoubleClickZoom: false,
      });
      let marker = new qq.maps.Marker({
        position: center,
        map,
      });
      let marker2 = new qq.maps.Marker({
        position: center2,
        map,
      });
      let anchor = new qq.maps.Point(0, 39),
        size = new qq.maps.Size(42, 68),
        origin = new qq.maps.Point(0, 0),
        markerIcon = new qq.maps.MarkerImage(
          '/static/img/gis1.png',
          size,
          origin,
          anchor
        );
      let anchor2 = new qq.maps.Point(0, 39),
        size2 = new qq.maps.Size(42, 68),
        origin2 = new qq.maps.Point(0, 0),
        markerIcon2 = new qq.maps.MarkerImage(
          '/static/img/weizhi.png',
          size2,
          origin2,
          anchor2
        );
      marker2.setIcon(markerIcon);
      marker.setIcon(markerIcon2);
    },
    getComplaint (page = 1, type) {
      let that = this;
      let params = {};
      params.data = {};
      params.data.page = page;
      params.data.pageSize = this.Page.pageSize;
      params.data.order = { report_time: -1 };
      params.data.searchValue = { river_name: '测试河|#|ne' };
      if (type !== undefined) {
        params.data.searchValue.solve_is = type;
        this.type_solve_is = type;
      }
      params.data.chooise = 'respon';
      params.token = storage.session.get('token');
      params.url = this.complaintList;
      if (this.searchItem.river_name !== '') {
        params.data.searchValue.river_name = `${this.searchItem.river_name}|#|like`;
      }
      if (this.searchItem.chref_name !== '') {
        params.data.searchValue[
          'respon_chief.realname'
        ] = `${this.searchItem.chref_name}|#|like`;
      }
      if (this.searchItem.report_time.length != 0) {
        params.data.searchValue.report_time = `${this.searchItem.report_time[0]} 00:00:00|#|${this.searchItem.report_time[1]} 23:59:59`;
      }
      if (this.searchItem.deps.length != 0) {
        params.data.searchValue[
          'location.dep_name'
        ] = `${this.searchItem.deps}|#|like`;
      }
      if (this.searchItem.report_no !== '') {
        params.data.searchValue.report_no = `${this.searchItem.report_no}|#|like`;
      }
      if (this.searchItem.user_type !== '') {
        params.data.searchValue.user_type = this.searchItem.user_type;
      }
      if (this.searchItem.solve_way !== '') { // 处理方式
        params.data.searchValue.solve_way = this.searchItem.solve_way;
      }
      if (this.searchItem.overday !== '') {
        params.data.searchValue.over_day = parseInt(this.searchItem.overday);
      }
      if (this.searchItem.is_multiple === true) {
        params.data.searchValue.is_multiple = '1';
      }
      if (type !== '已处理') {
        if (this.searchItem.can_use === true) {
          params.data.addparam = true;
        }
      }
      params.success = function (res) {
        that.$Loading.finish();
        if (type == '已处理') {
          that.completeData = res.data.result.result;
        } else if (type == '处理中') {
          that.solveData = res.data.result.result;
          that.complete_num = res.data.result.totalSize;
        }
        that.addBadge();
        that.Page.total = res.data.result.totalSize;
      };
      ajaxPost(params);
    },
    changePage (page) {
      this.getComplaint(page, this.type_solve_is);
      this.actionPage = page;
    },
    change (data) {
      if (data[0] === '') {
        this.searchItem.report_time = [];
        return;
      }
      this.searchItem.report_time = data;
    },
    send () {
      let that = this;
      let params = {};
      params.data = {};
      if (this.type === '1') {
        params.data.solve_result = this.solve_result2;
        params.data.solve_file = [];
        this.uploadList.map(item => {
          params.data.solve_file.push(item.url);
        });
        params.url = this.urlJieSu2;
      }
      if (this.type === '2') {
        params.data.solve_result = this.solve_result2;
        params.data.solve_file = [];
        this.uploadList.map(item => {
          params.data.solve_file.push(item.url);
        });
        params.url = this.urlJieSu;
      }
      params.data._id = this.row._id;
      params.token = storage.session.get('token');
      params.success = function (res) {
        if (res.data.code == '0000') {
          that.$Message.info({
            content: res.data.message,
          });
          that.getComplaint(that.actionPage, that.type_solve_is);
          that.addBadge();
          that.complete_opinion2 = '';
          that.comfirmModal = false;
        } else {
          that.$Notice.open({
            title: res.data.message,
          });
        }
      };
      ajaxPost(params);
    },
    print (row, type) {
      if (type == '1') {
        this.printshow = true;
      } else {
        this.printshow = false;
      }
      if (row.solve_file) {
        this.reply_result = row.reply_result;
        this.showImgLoad = row.solve_file;
      } else {
        this.showImgLoad = [];
        this.reply_result = '';
      }
      if (row.score) {
        this.score = row.score;
      } else {
        this.score = {
          speed: 0,
          attitude: 0,
          merge: 0,
          evaluate: '',
        };
      }
      this.user_type = row.user_type;
      this.jinduData = row.records;
      this.printModal = true;
      this.address = row.address;
      this.phone = row.phone;
      this.contacts = row.contacts;
      this.river_name = row.river_name;
      this.report_time = row.report_time;
      this.report_no = row.report_no;
      this.confirm_person = '河长办';
      this.is_secrecy = row.is_secrecy;
      this.contacts_id = row.contacts_id;
      this.overview = row.overview;
      this.complete_opinion = row.complete_opinion;
      this.solve_result = row.solve_result;
      if (row.overseer !== undefined) {
        this.advice = row.overseer.advice;
      } else {
        this.advice = '';
      }
    },
    ok () {
      let that = this;
      let params = {};
      params.data = {
        address: this.address,
        phone: this.phone,
        contacts: this.contacts,
        river_name: this.river_name,
        report_time: this.report_time,
        report_no: this.report_no,
        confirm_person: this.confirm_person,
        overview: this.overview,
        complete_opinion: this.complete_opinion,
        contacts_id: this.contacts_id,
      };
      params.url = this.docList;
      params.token = storage.session.get('token');
      params.success = function (res) {
        that.$Message.success({
          content: res.data.message,
        });
        window.open(domain2 + res.data.result);
      };
      ajaxPost(params);
    },
    showModal (row, type) {
      this.row = row;
      this.type = type;
      this.solve_result2 = '';
      this.comfirmModal = true;
      if (type == '2') {
        this.solve = true;
        this.check = false;
        this.uploadUrl = `${domain}/filemanage/uploadphoto?dir=reportPhoto/solveFile/${row.report_no
          }&token=${storage.session.get('token')}`;
        setTimeout(() => {
          this.uploadList = this.$refs.upload.fileList;
          if (this.uploadList.length > 0) {
            this.$refs.upload.clearFiles();
            this.uploadList = this.$refs.upload.fileList;
          }
        }, 200);
      }
      if (type == '4') {
        this.solve = false;
        this.check = true;
        this.solve_result2 = row.solve_result;
        this.uploadList = row.solve_file;
      }
    },
    addBadge () {
      let that = this;
      $('.ivu-tabs-tab:eq(0)').html('处理中');
      if (that.complete_num == '') {
        $('.ivu-tabs-tab:eq(0)').append("<sup class='ivu-badge-count'>0</sup>");
      } else {
        $('.ivu-tabs-tab:eq(0)').append(
          `<sup class='ivu-badge-count'>${that.complete_num}</sup>`
        );
      }
    },
    getAddress () {
      let that = this;
      let params = {
        data: {
          searchValue: {},
          fieldName: 'dep_name',
          type: 'String',
        },
        token: storage.session.get('token'),
        url: this.urlAddressList,
        success: res => {
          console.log(res);
          this.areaArr = res.data.result;
        },
      };
      if (storage.session.get('level') == '2') {
        params.data.searchValue.level2 = storage.session.get('dep_name');
        params.data.searchValue.level = 3;
      }
      ajaxPost(params);
    },
    handleRemove (file) {
      const fileList = this.$refs.upload.fileList;
      this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
    },
    handleSuccess (res, file) {
      file.url = res.result.path;
      file.name = res.result.filename;
    },
    handleFormatError (file) {
      this.$Notice.warning({
        title: '文件格式不正确',
        desc: `文件格式不正确，请上传 jpg 或 png 格式的图片。`,
      });
    },
    handleMaxSize (file) {
      this.$Notice.warning({
        title: '超出文件大小限制',
        desc: `文件太大，不能超过 20M。`,
      });
    },
    handleBeforeUpload () {
      const check = this.$refs.upload.fileList.length < 7;
      if (!check) {
        this.$Notice.warning({
          title: '最多只能上传 7 张图片。',
        });
      }
      return check;
    },
    getTongJiUser () {
      let params = {
        data: {
          dep_name: this.saveRow.location.dep_name,
          type: '2',
        },
        url: this.urlCherfList,
        token: storage.session.get('token'),
        success: res => {
          this.userList = res.data.result;
          this.$Loading.finish();
        },
      };
      ajaxPost(params);
    },
    getXiaSuDep () {
      let params = {
        data: {
          searchValue: {
            level: parseInt(this.saveRow.location.level) + 1,
          },
        },
        url: this.urlDepList,
        token: storage.session.get('token'),
        success: res => {
          this.depList = res.data.result.result;
          this.$Loading.finish();
        },
      };
      if (this.saveRow.location.level == '1') {
        params.data.searchValue.level1 = this.saveRow.location.dep_name;
      } else if (this.saveRow.location.level == '2') {
        params.data.searchValue.level2 = this.saveRow.location.dep_name;
      } else if (this.saveRow.location.level == '3') {
        params.data.searchValue.level3 = this.saveRow.location.dep_name;
      }
      ajaxPost(params);
    },
    assign () {
      let params = {
        data: {
          _id: this.saveRow._id,
          report_no: this.saveRow.report_no,
          username: this.username,
        },
        url: this.urlAssignCherf,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code === '0000') {
            this.$Message.success({
              content: '上报成功',
            });
            this.$Loading.finish();
            this.getComplaint('1', this.type_solve_is);
          } else {
            this.$Message.warning({
              content: `${res.data.message}上报失败`,
            });
          }
        },
      };
      if (this.dep_name !== '') {
        params = {
          data: {
            _id: this.saveRow._id,
            report_no: this.saveRow.report_no,
            dep_name: this.dep_name,
          },
          url: this.urlAssignDep,
          token: storage.session.get('token'),
          success: res => {
            if (res.data.code === '0000') {
              this.$Message.success({
                content: '指派成功',
              });
              this.$Loading.finish();
              this.getComplaint('1', this.type_solve_is);
            } else {
              this.$Message.warning({
                content: `${res.data.message}指派失败`,
              });
            }
          },
        };
      }
      ajaxPost(params);
    },
    backDep () {
      let params = {
        data: {
          _id: this.saveRow._id,
          report_no: this.saveRow.report_no,
          reason: this.formItem1.reason,
        },
        url: this.urlAssignUp,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code === '0000') {
            this.$Message.success({
              content: '返回成功',
            });
            this.$Loading.finish();
            this.getComplaint('1', this.type_solve_is);
            this.backModal = false;
          } else {
            this.$Message.warning({
              content: `${res.data.message}返回失败`,
            });
          }
        },
      };
      ajaxPost(params);
    },
    getHostDep () {
      let params = {
        data: {
          searchValue: {
            level: parseInt(storage.session.get('level')),
            type: '1',
          },
          type: 'String',
          fieldName: 'dep_name',
        },
        url: this.urlHostDepList,
        token: storage.session.get('token'),
        success: res => {
          this.host_depList = res.data.result;
          this.$Loading.finish();
        },
      };
      ajaxPost(params);
    },
    assDep () {
      if (this.host_dep === '') {
        this.$Message.warning({
          content: '请选取主办单位',
        });
      } else {
        let params = {
          data: {
            host_dep: this.host_dep,
            assist_dep: this.assist_dep,
            _id: this.saveRow._id,
            chief_advice: this.chief_advice,
          },
          url: this.urlAssDep,
          token: storage.session.get('token'),
          success: res => {
            if (res.data.code === '0000') {
              this.$Message.success({
                content: '指派成功',
              });
              this.$Loading.finish();
              this.getComplaint('1', this.type_solve_is);
              this.companyModal = false;
            } else {
              this.$Message.warning({
                content: `${res.data.message}指派失败`,
              });
            }
          },
        };
        ajaxPost(params);
      }
    },
    review (type) {
      let params = {
        data: {
          _id: this.row._id,
          report_no: this.row.report_no,
        },
        url: this.urlReview,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code === '0000') {
            this.$Message.success({
              content: '操作成功',
            });
            this.$Loading.finish();
            this.getComplaint('1', this.type_solve_is);
            this.comfirmModal = false;
          } else {
            this.$Message.warning({
              content: `${res.data.message}操作失败`,
            });
          }
        },
      };
      if (type === 'true') {
        params.data.pass = true;
      } else if (type === 'false') {
        params.data.pass = false;
        params.data.solve_file = this.row.solve_file;
        params.data.solve_result = this.row.solve_result;
        params.data.solve_time = this.row.solve_time;
        params.data.reason = this.reason;
      }
      ajaxPost(params);
    },
    handleView (name) {
      this.imgName = name;
      this.visible = true;
    },
    rowClassName (row) {
      let today = new Date().format('yyyy-MM-dd');
      if (today > row.plan_time) {
        return 'bg-red';
      }
      if (row.is_multiple == '1') {
        return 'bg-orange';
      }
    },
    checkIn (type) {
      let params = {
        data: {
          _id: this.saveRow._id,
          report_no: this.saveRow.report_no,
        },
        url: '/emergency/report/examine_process',
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Message.success({
              content: '操作成功',
            });
            this.$Loading.finish();
            this.comfirmModal1 = false;
            this.getComplaint('1', this.type_solve_is);
          } else {
            this.$Message.warning({
              content: `${res.data.message}操作失败`,
            });
          }
        },
      };
      if (type === 'true') {
        params.data.pass = true;
      } else if (type === 'false') {
        params.data.pass = false;
        params.data.reason = this.reason;
      }
      ajaxPost(params);
    },
    getMyData () {
      let params = {
        data: {
          page: this.Page.Page,
          pageSize: this.Page.pageSize,
          order: { report_time: -1 },
        },
        url: '/emergency/report/myreport',
        token: storage.session.get('token'),
        success: res => {
          this.myData = res.data.result.result;
          this.Page.total = res.data.result.totalSize;
        },
      };
      ajaxPost(params);
    },
    doMySelf () {
      let params = {
        data: {
          _id: this.saveRow._id,
        },
        url: this.urlMySelf,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code === '0000') {
            this.$Message.success({
              content: '指定成功',
            });
            this.$Loading.finish();
            this.getComplaint('1', this.type_solve_is);
          } else {
            this.$Message.warning({
              content: `${res.data.message}指定失败`,
            });
          }
        },
      };
      ajaxPost(params);
    },
    getDepData (data) {
      if (data === undefined) {
        this.searchItem.deps = '';
      } else {
        this.searchItem.deps = data;
      }
    },
    // 打印巡河记录表
    printPatrol () {
      let iframe = document.getElementById('patrolTable');
      iframe.contentWindow.focus();
      iframe.contentWindow.print();
      this.printPatrolModal = false;
    },
  },
  mounted () {
    this.getComplaint('1', '处理中');
    this.getAddress();
    this.getHostDep();
    this.addBadge();
    this.$Notice.open({
      title: '红色为超时事件，黄色为多次事件',
    });
    let that = this;
    // this.complaintColumns = chiefComplaintColumns(that)
    this.complaintColumns = complaintColumns(that);
  },
  watch: {
    'searchItem.is_multiple' (data) {
      this.getComplaint('1', this.type_solve_is);
    },
    'searchItem.can_use' (data) {
      this.getComplaint('1', this.type_solve_is);
    },
  },
};
</script>
